package com.situ.hr4.w.dao;

import com.situ.hr4.pojo.EngageInterview;
import com.situ.hr4.pojo.EngageResume;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

//面试管理
@Mapper
public interface MSGLdao {
    //有限简历全查
    @Select("select res_id,human_name,human_sex,c.major_kind_id,c.major_kind_name,b.major_id,major_name,human_telephone,interview_status from engage_resume a inner join config_major b \n" +
            "\t\t\ton a.human_major_id=b.major_id\n" +
            "\t\t\tinner join config_major_kind c \n" +
            "\t\t\t\ton c.major_kind_id=b.major_kind_id\n" +
            "\t\t\t\twhere check_status=2")
    List<Map> jlqc();

    //根据id查面试表和简历
    @Select("select interview_amount,image_degree,native_language_degree,foreign_language_degree,response_speed_degree,EQ_degree,IQ_degree,multi_quality_degree,a.register,a.interview_comment,a.register,a.registe_time,a.checker,a.check_time,pass_checkComment,pass_passComment from engage_interview a inner join engage_resume b on a.resume_id=b.res_id and res_id=#{value}\n")
    Map qc(int id);

    //根据简历id修改面试表中的信息
    @Update("update engage_interview set human_name=#{human_name},image_degree=#{image_degree},native_language_degree=#{native_language_degree},foreign_language_degree=#{foreign_language_degree},response_speed_degree=#{response_speed_degree},EQ_degree=#{EQ_degree},IQ_degree=#{IQ_degree},multi_quality_degree=#{multi_quality_degree},registe_time=#{registe_time},interview_comment=#{interview_comment},register=#{register} where resume_id=#{id} ")
    void update(EngageInterview e );

    //修改简历表的数量和未面试、待面试的状态
    @Update("update engage_resume set interview_amount=#{interview_amount},interview_status=2 where interview_status=0 or interview_status=1")
    void updatesl(EngageResume ers);

    //查询所有面试结果列表
    @Select("select a.res_id,a.human_name,b.major_id,b.major_name,c.major_kind_id,c.major_kind_name,a.interview_amount,d.registe_time,d.multi_quality_degree from engage_resume a \n" +
            "\t\tinner join config_major b on a.human_major_id=b.major_id\n" +
            "\t\tinner join config_major_kind c on b.major_kind_id=c.major_kind_id\n" +
            "\t\tinner join engage_interview d on d.resume_id=a.res_id where interview_amount>=1 and a.check_status=2 and a.interview_status!=4 and a.interview_status!=5 and a.interview_status!=6 ")
    List<Map> cxjblb();

    //根据简历id修改面试表筛选人、时间
    @Update("update engage_interview set check_comment=#{check_comment},checker=#{checker},check_time=#{check_time} where resume_id=#{id}\n")
    void xgmsb(EngageInterview e);

    //根据简历id修改简历表的面试状态
    @Update("update engage_resume set interview_status=#{interview_status} where res_id=#{res_id}")
    void xgjl(EngageResume e);

    //根据简历id删除简历
    @Delete("delete engage_resume where res_id=#{value}")
    void scjl(int id);

    //根据简历id删除面试信息
    @Delete("delete engage_interview where resume_id=#{value}")
    void scmsxx(int id);
}
